import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

/**
 * @author 帅小伙
 * @date 2022/1/3
 * @description
 */
public class Consumer62 {

    private static final String DEAD_QUEUE_NAME = "dead_queue";

    public void consume() throws Exception {
        Channel channel = RabbitMqUtils.getChannel();
        System.out.println(Thread.currentThread().getName() + "  消费者启动等待消费.........");


        String name = Thread.currentThread().getName();
        DeliverCallback deliverCallback = (consumerTag, delivery) -> {
            String message = new String(delivery.getBody());
            System.out.println(name + "接收到的死信消息" + message);
        };

        channel.basicConsume(DEAD_QUEUE_NAME, true, deliverCallback, (consumerTag) -> {
            System.out.println(consumerTag + "消费者取消消费信息");
        });
        //
    }
}
